##cka-init.sh

KUBERNETES_VERSION=v1.22.1
KUBERNETES_IMAGE_REPOSITORY=registry.cn-hangzhou.aliyuncs.com/containers-google

# 初始化k8s集群

#gunzip -c k8s-v1.22.4.tar.gz | docker load

kubeadm init --pod-network-cidr 192.168.0.0/16 --kubernetes-version ${KUBERNETES_VERSION} --image-repository ${KUBERNETES_IMAGE_REPOSITORY}
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# 添加网络插件
#gunzip -c calico-v3.21.1.tar.gz | docker load

# Install the Tigera Calico operator and custom resource definitions
kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml

# Install Calico by creating the necessary custom resource
kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml

# 查看 pods 和 nodes 状态
kubectl get pods --all-namespaces
kubectl get nodes

kubectl taint nodes $(hostname) node-role.kubernetes.io/master:NoSchedule-

# 添加共享存储插件
#gunzip -c longhorn-v1.2.2.tar.gz | docker load
